package com.bml.architect.redis.source;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class RedisCluster {


    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(10);
        config.setMaxTotal(20);
        config.setMinIdle(5);
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.56.120", 7001));
        jedisClusterNode.add(new HostAndPort("192.168.56.120", 7002));
        jedisClusterNode.add(new HostAndPort("192.168.56.121", 8001));
        jedisClusterNode.add(new HostAndPort("192.168.56.121", 8002));
        jedisClusterNode.add(new HostAndPort("192.168.56.122", 9001));
        jedisClusterNode.add(new HostAndPort("192.168.56.122", 9002));
        JedisCluster cluster = new JedisCluster(jedisClusterNode,6000,6000,10,"baiml",config);
        System.out.println(cluster.set("cluster", "11111"));
        System.out.println(cluster.get("cluster"));
    }
}
